package org.hhchat.others.tercent;

import java.util.Scanner;

/**
 * Created by HMH on 2017/4/3.
 */
public class t02 {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String input = scanner.nextLine();

        int nums[]=new int[4] ;


        int count=0;
        for(int i=1;i<=input.length();i++) {
            nums[input.charAt(i-1)-'A']++;
            for(int j=input.charAt(i-1)-'A'+1;j<4;j++){
                count+=nums[j];
                if(nums[j]!=0)
                System.out.println(input.charAt(i-1)+"--->"+(char)(j+'A'));
            }
        }

        System.out.println(count);
    }
}
